package com.wyp168.juc;

/**
 * @ClassName InterruptedDemo002
 * @Description TODO
 * @Author wyp168
 * @Date 2022/7/8 14:52
 */
public class InterruptedDemo002 {
    public static void main(String[] args) throws InterruptedException {
        Thread threadA = new Thread(() -> {
            while (!Thread.interrupted()) {

            }

            System.out.println("ThreadA isInterrupt: " + Thread.currentThread().isInterrupted());
        });

        //启动线程
        threadA.start();

        //在主线程中调用方法来中断ThreadA线程
        threadA.interrupt();

//        Thread.sleep(1000);

        System.out.println(threadA.isInterrupted());

        threadA.join();

        System.out.println("Main Thread over!");
    }
}
